package com.meetflow.conference.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.meetflow.common.annotation.Log;
import com.meetflow.common.core.controller.BaseController;
import com.meetflow.common.core.domain.AjaxResult;
import com.meetflow.common.enums.BusinessType;
import com.meetflow.conference.domain.MeetApproval;
import com.meetflow.conference.service.IMeetApprovalService;
import com.meetflow.common.utils.poi.ExcelUtil;
import com.meetflow.common.core.page.TableDataInfo;

/**
 * 会议管理流程配置Controller
 * 
 * @author duan
 * @date 2024-07-11
 */
@RestController
@RequestMapping("/conference/approval")
public class MeetApprovalController extends BaseController
{
    @Autowired
    private IMeetApprovalService meetApprovalService;

    /**
     * 查询会议管理流程配置列表
     */
    @PreAuthorize("@ss.hasPermi('conference:approval:list')")
    @GetMapping("/list")
    public TableDataInfo list(MeetApproval meetApproval)
    {
        startPage();
        List<MeetApproval> list = meetApprovalService.selectMeetApprovalList(meetApproval);
        return getDataTable(list);
    }

    /**
     * 导出会议管理流程配置列表
     */
    @PreAuthorize("@ss.hasPermi('conference:approval:export')")
    @Log(title = "会议管理流程配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MeetApproval meetApproval)
    {
        List<MeetApproval> list = meetApprovalService.selectMeetApprovalList(meetApproval);
        ExcelUtil<MeetApproval> util = new ExcelUtil<MeetApproval>(MeetApproval.class);
        util.exportExcel(response, list, "会议管理流程配置数据");
    }

    /**
     * 获取会议管理流程配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('conference:approval:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(meetApprovalService.selectMeetApprovalById(id));
    }

    /**
     * 新增会议管理流程配置
     */
    @PreAuthorize("@ss.hasPermi('conference:approval:add')")
    @Log(title = "会议管理流程配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeetApproval meetApproval)
    {
        return toAjax(meetApprovalService.insertMeetApproval(meetApproval));
    }

    /**
     * 修改会议管理流程配置
     */
    @PreAuthorize("@ss.hasPermi('conference:approval:edit')")
    @Log(title = "会议管理流程配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MeetApproval meetApproval)
    {
        return toAjax(meetApprovalService.updateMeetApproval(meetApproval));
    }

    /**
     * 删除会议管理流程配置
     */
    @PreAuthorize("@ss.hasPermi('conference:approval:remove')")
    @Log(title = "会议管理流程配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(meetApprovalService.deleteMeetApprovalByIds(ids));
    }
}
